﻿using System;
using ZFine.Application.Gas;
using ZFine.Code;
using ZFine.Domain.Entity.Gas;
using System.Collections.Generic;
using System.Linq;
using System.Web.Mvc;

namespace ZFine.Web.Areas.Gas.Controllers
{
    public class BottleController : ControllerBase
    {
        private BottleApp bottleApp = new BottleApp();
        [HttpGet]
        [HandlerAuthorize(ignore: false)]
        public override ActionResult Index()
        {
            return View();
        }
        [HttpGet]
        [HandlerAuthorize(ignore: false)]
        public override ActionResult Form()
        {
            return View();
        }
        [HandlerAuthorize(ignore: false)]
        public override ActionResult Details()
        {
            return View();
        }
        [HttpGet]
        [HandlerAjaxOnly]
        public ActionResult GetGridJson(Pagination pagination, string keyword)
        {
            var data = new
            {
                rows = bottleApp.GetList(pagination, keyword),
                total = pagination.total,
                page = pagination.page,
                records = pagination.records
            };
            return Content(data.ToJson());
        }
        [HttpGet]
        [HandlerAjaxOnly]
        public ActionResult GetFormJson(string keyValue)
        {
            var data = bottleApp.GetForm(keyValue);
            return Content(data.ToJson());
        }
        [HttpPost]
        [HandlerAjaxOnly]
        [ValidateAntiForgeryToken]
        public ActionResult SubmitForm(BottleEntity BottleEntity, string permissionIds, string keyValue)
        {
            bottleApp.SubmitForm(BottleEntity, keyValue);
            return Success("操作成功。");
        }
        [HttpPost]
        [HandlerAjaxOnly]
        //[HandlerAuthorize]
        [ValidateAntiForgeryToken]
        public ActionResult DeleteForm(string keyValue)
        {
            bottleApp.DeleteForm(keyValue);
            return Success("删除成功。");
        }

    }
}
